package com.wsy.service;

import com.wsy.Pojo.User;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;

@Service("userService")
public class UserService {

    private static Map<Integer, User> map=new HashMap<>();

    static {
        map.put(1,new User(1,"张三",3600.0, LocalDate.parse("2000-02-02"), LocalDateTime.now()));
        map.put(2,new User(2,"大师",3600.0, LocalDate.parse("2000-02-02"), LocalDateTime.now()));
        map.put(3,new User(3,"撒旦",3600.0, LocalDate.parse("2000-02-02"), LocalDateTime.now()));
    }


    public List<User> getAll(){
        List<User> list=new ArrayList<>(map.values());
        return list;
    }

    public void add(User user){
        Set<Integer> key=map.keySet();
        Integer id=Collections.max(key)+1;
        user.setId(id);
        map.put(user.getId(),user);
    }

    public void update(User user){
        map.put(user.getId(),user);
    }

    public void del(Integer id){
        map.remove(id);
    }



}
